package com.haoxin.ai_course.modules.course.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.haoxin.ai_course.common.base.AbstractController;
import com.haoxin.ai_course.common.utils.HttpJsonResult;
import com.haoxin.ai_course.modules.course.biz.AcNodeUserBusiness;
import com.haoxin.ai_course.modules.course.entity.AcNodeUser;
import com.haoxin.ai_course.modules.course.entity.PO.AcNodeUserCourseIDPO;
import com.haoxin.ai_course.modules.course.entity.VO.AcNodeUserVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;



/**
 * 环节用户表
 * 
 * @author xingxiangguo
 * @email bugcn@qq.com
 * @date 2022-06-10 17:24:28
 */
@RestController
@RequestMapping("/app/course/acnodeuser")
@Api(value="api",tags="app小程序-用户课程环节管理")
public class AcNodeUserController  extends AbstractController {
   @Autowired
   AcNodeUserBusiness acNodeUserBusiness;

   @GetMapping("/getListByCourseId")
   @ApiOperation("根据课程id获取环节列表")
   public HttpJsonResult<List<AcNodeUserVO>> getListByCourseId(@ApiParam("课程id") @RequestParam("courseId")  Integer courseId){
	   return acNodeUserBusiness.getListByCourseId(courseId,getUserId(),getUser().getMobile());
   }
   @GetMapping("/getNodeById")
   @ApiOperation("根据环节id获取环节")
   public HttpJsonResult<AcNodeUserVO> getNodeById(@ApiParam("环节id") @RequestParam("nodeId")  Integer nodeId,@ApiParam("课程id")@RequestParam("courseId") Integer courseId){
	   return acNodeUserBusiness.getNodeById(nodeId,getUserId(),courseId);
   }
   @PostMapping("/changeNodeStatus")
   @ApiOperation("修改环节状态")
   public HttpJsonResult<Boolean> changeNodeStatus(
		    @RequestBody AcNodeUser acNodeUser
		   ){
	   return acNodeUserBusiness.changeNodeStatus(acNodeUser.getNodeId(),getUserId(),acNodeUser.getCourseId(),acNodeUser.getStudyStatus(),acNodeUser.getNextNodeId());
   }
   @PostMapping("/changeAllNodeStatus")
   @ApiOperation("修改所有课程的环节状态")
   public HttpJsonResult<Boolean> changeAllNodeStatus(
		   @RequestBody AcNodeUserCourseIDPO acNodeUser
		   ){
	   return acNodeUserBusiness.changeAllNodeStatus(getUserId(),acNodeUser.getCourseId(),acNodeUser.getStudyStatus(),getUser().getMobile());
   }
}
